clear all
set more off

use replication, clear


* DEFINE GLOBALS

global coop "coop2 coop3 coop4 coop5 coop6 coop7 coop8 coop9 coop10 coop11 coop12"
global indvars "age write ihs_landsize assets_agr no_0_18 no_19_54_fem no_19_54_male no_55plus"
global basevars "age write ihs_landsize assets_agr no_0_18 no_19_54_fem no_19_54_male no_55plus riskav recent_idioshock shdisprev shseed shfert sh_flatparcel"


* SUMMARY STATISTICS

sum sdarea ocmaincroptercyie octefftercyie unlikeliness unlikeliness_extreme unlikeliness_drought_extreme age write ihs_landsize assets_agr no_0_18 no_19_54_fem no_19_54_male no_55plus switch riskav recent_idioshock shdisprev shseed shfert sh_flatparcel


* CORRELATION MATRIX

pwcorr ocmaincroptercyie unlikeliness z_sd age write ihs_landsize assets_agr switch riskav no_0_18 no_19_54_fem no_19_54_male no_55plus recent_idioshock shdisprev shseed shfert sh_flatparcel, star(.10)


* REGRESSION TABLE: Unrealistically positive self-evaluation (based on the main crop, i.e. the crop occupying the largest area) and risk-taking

estimates clear

reg z_sd ocmaincroptercyie, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "No", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_01

reg z_sd ocmaincroptercyie $coop, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_02

reg z_sd ocmaincroptercyie $indvars switch $coop, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_03

reg z_sd ocmaincroptercyie $indvars riskav $coop, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_04

reg z_sd ocmaincroptercyie $basevars $coop, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_05

reg z_sd ocmaincroptercyie $basevars a27_1 a27_3 a27_4 a27_5 a27_6 a27_7 mighh nonagr othersdecide littlecontrol trustpeople impatient i.selfevtercsoil i.selfevtercprofit i.landterc i.ageterc i.assets_agrterc $coop, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "Yes", replace
estadd local perstrait "Yes", replace
estadd local selfeval "Yes", replace
est sto ocm_06

reg z_sd ocmaincroptercyie $basevars $coop if maincropterc != 2, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_07

reg z_sd ocmaincroptercyie $basevars $coop if maincropnoloss == 1, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_08

gen ocmaincroptercyie2 = ocmaincroptercyie
replace ocmaincroptercyie = ocmaincroptercagr
reg z_sd ocmaincroptercyie $basevars $coop, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_10
replace ocmaincroptercyie = ocmaincroptercyie2
 
reg z_sd_constpr ocmaincroptercyie $basevars $coop, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_11

reg z_sd_total ocmaincroptercyie $basevars $coop, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_12

reg z_sd ocallcropstercyie $basevars $coop, robust
boottest ocallcropstercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_13

esttab * using "ocmaincrop.tex", replace label drop(_cons coop* a27_1 a27_3 a27_4 a27_5 a27_6 a27_7 mighh nonagr othersdecide littlecontrol trustpeople impatient *selfevtercsoil* *selfevtercprofit* *landterc* *ageterc* *assets_agrterc*) star(* 0.1 ** 0.05 *** 0.01) nomtitles ///
se(%4.3f) b(%4.3f) nogaps stat(clustered commfixed insurance perstrait selfeval r2 N, fmt(2 3 3 3 3 2 0) label("\shortstack[l]{P-value for unrealistically positive self-evaluation\\with std. err. clustered at community level}" "Community fixed effects" "Controls for access to informal insurance" "Personality traits" "Additional measures of (self-)perception" "R2" "Observations")) nonotes order(ocmaincroptercyie ocallcropstercyie)


* REGRESSION TABLE: Unrealistically positive self-evaluation (based on Teff) and risk-taking

estimates clear

reg z_sd octefftercyie, robust
boottest octefftercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "No", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_01

reg z_sd octefftercyie $coop, robust
boottest octefftercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_02

reg z_sd octefftercyie $indvars switch $coop, robust
boottest octefftercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_03

reg z_sd octefftercyie $indvars riskav $coop, robust
boottest octefftercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_04

reg z_sd octefftercyie $basevars $coop, robust
boottest octefftercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_05

reg z_sd octefftercyie $basevars a27_1 a27_3 a27_4 a27_5 a27_6 a27_7 mighh nonagr othersdecide littlecontrol trustpeople impatient i.selfevtercsoil i.selfevtercprofit i.landterc i.ageterc i.assets_agrterc $coop, robust
boottest octefftercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "Yes", replace
estadd local perstrait "Yes", replace
estadd local selfeval "Yes", replace
est sto ocm_06

reg z_sd octefftercyie $basevars $coop if teffterc != 2, robust
boottest octefftercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_07

reg z_sd octefftercyie $basevars $coop if teffnoloss == 1, robust
boottest octefftercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_08

gen octefftercyie2 = octefftercyie
replace octefftercyie = octefftercagr
reg z_sd octefftercyie $basevars $coop, robust
boottest octefftercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_10
replace octefftercyie = octefftercyie2
 
reg z_sd_constpr octefftercyie $basevars $coop, robust
boottest octefftercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_11

reg z_sd_total octefftercyie $basevars $coop, robust
boottest octefftercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
estadd local selfeval "No", replace
est sto ocm_12

esttab * using "octeff.tex", replace label drop(_cons coop* a27_1 a27_3 a27_4 a27_5 a27_6 a27_7 mighh nonagr othersdecide littlecontrol trustpeople impatient *selfevtercsoil* *selfevtercprofit* *landterc* *ageterc* *assets_agrterc*) star(* 0.1 ** 0.05 *** 0.01) nomtitles ///
se(%4.3f) b(%4.3f) nogaps stat(clustered commfixed insurance perstrait selfeval r2 N, fmt(2 3 3 3 3 2 0) label("\shortstack[l]{P-value for unrealistically positive self-evaluation\\with std. err. clustered at community level}" "Community fixed effects" "Controls for access to informal insurance" "Personality traits" "Additional measures of (self-)perception" "R2" "Observations")) nonotes order(octefftercyie)


* REGRESSION TABLE: Heterogeneity in the relationship between unrealistically positive self-evaluation and risk-taking

estimates clear

lab var ocmaincroptercyie "Unrealistically positive self-evaluation"

* by distance to market
reg z_sd ocmaincroptercyie $basevars $coop if dist_3 <= 2, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
est sto ocm_het_01a

reg z_sd ocmaincroptercyie $basevars $coop if dist_3 > 2, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
est sto ocm_het_01b

* by sale consumption ratio
reg z_sd ocmaincroptercyie $basevars $coop if saleconsratio >= 1 & saleconsratio !=. , robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
est sto ocm_het_02a

reg z_sd ocmaincroptercyie $basevars $coop if saleconsratio < 1, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
est sto ocm_het_02b

* by cashcrop
reg z_sd ocmaincroptercyie $basevars $coop if cashcrop == 1, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
est sto ocm_het_03a

reg z_sd ocmaincroptercyie $basevars $coop if cashcrop == 0, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
est sto ocm_het_03b

* by cultivated land size
reg z_sd ocmaincroptercyie $basevars $coop if ihs_landcultivated > 3.2, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
est sto ocm_het_04a

reg z_sd ocmaincroptercyie $basevars $coop if ihs_landcultivated <= 3.2, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
est sto ocm_het_04b

* by age
reg z_sd ocmaincroptercyie $basevars $coop if age <= 48, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
est sto ocm_het_05a

reg z_sd ocmaincroptercyie $basevars $coop if age > 48, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
est sto ocm_het_05b

* experienced severe shock
reg shock_severe ocmaincroptercyie $basevars $coop, robust
boottest ocmaincroptercyie = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
est sto ocm_shock

esttab ocm_het_01* ocm_het_02* ocm_het_03* ocm_het_04* ocm_het_05* ocm_shock using "heterogeneity.tex", replace label keep(ocmaincroptercyie) star(* 0.1 ** 0.05 *** 0.01) ///
se(%4.3f) b(%4.3f) nogaps stat(clustered commfixed controls r2 N, fmt(2 3 3 2 0) label("\shortstack[l]{P-value for unrealistically positive self-evaluation\\with std. err. clustered at community level}" "Community fixed effects" "Control variables" "R2" "Observations")) nonotes ///
mtitles("\shortstack[c]{below\\median}" "\shortstack[c]{above\\median}" ">=1" "<1" "\shortstack[c]{cash\\crops}" "\shortstack[c]{no cash\\crops}" "\shortstack[c]{above\\median}" "\shortstack[c]{below\\median}" "\shortstack[c]{below\\median}" "\shortstack[c]{above\\median}" "\shortstack[c]{Experienced\\severe\\shock}") ///
mgroups("\shortstack[c]{Distance to market\\(median: 2 km)}" "\shortstack[c]{Sale-consumption\\ratio}" "\shortstack[c]{Cash crop\\farmer}" "\shortstack[c]{Land size\\(median: 3.2 hectare)}" "\shortstack[c]{Age\\(median: 48 years)}" "\shortstack[c]{Additional\\outcome}", pattern(1 0 1 0 1 0 1 0 1 0 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))


* REGRESSION TABLE: Optimism and risk-taking

estimates clear

reg z_sd unlikeliness, robust
boottest unlikeliness = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "No", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
est sto unl_01

reg z_sd unlikeliness $coop, robust
boottest unlikeliness = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
est sto unl_02

reg z_sd unlikeliness $indvars switch $coop, robust
boottest unlikeliness = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
est sto unl_03

reg z_sd unlikeliness $indvars riskav $coop, robust
boottest unlikeliness = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
est sto unl_04

reg z_sd unlikeliness $basevars $coop, robust
boottest unlikeliness = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
est sto unl_05

reg z_sd unlikeliness $basevars a27_1 a27_3 a27_4 a27_5 a27_6 a27_7 mighh nonagr othersdecide littlecontrol trustpeople impatient $coop, robust
boottest unlikeliness = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "Yes", replace
estadd local perstrait "Yes", replace
est sto unl_06

reg z_sd unlikeliness_extreme $basevars $coop, robust
boottest unlikeliness_extreme = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
est sto unl_07

reg z_sd unlikeliness_drought_extreme $basevars $coop, robust
boottest unlikeliness_drought_extreme = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
est sto unl_08

reg z_sd_constpr unlikeliness $basevars $coop, robust
boottest unlikeliness = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
est sto unl_09

reg z_sd_total unlikeliness $basevars $coop, robust
boottest unlikeliness = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local insurance "No", replace
estadd local perstrait "No", replace
est sto unl_10

esttab * using "unlikeliness.tex", replace label drop(_cons coop* a27_1 a27_3 a27_4 a27_5 a27_6 a27_7 mighh nonagr othersdecide littlecontrol trustpeople impatient) star(* 0.1 ** 0.05 *** 0.01) nomtitles ///
se(%4.3f) b(%4.3f) nogaps stat(clustered commfixed insurance perstrait r2 N, fmt(2 3 3 3 2 0) label("\shortstack[l]{P-value for optimism with std. err.\\clustered at community level}" "Community fixed effects" "Controls for access to informal insurance" "Personality traits" "R2" "Observations")) nonotes order(unlikeliness unlikeliness_extreme unlikeliness_drought_extreme)


* REGRESSION TABLE: IV estimates for optimism and risk-taking

global startage "20"
global endage "29"

estimates clear

ivreg2 z_sd $basevars $coop (unlikeliness = ihs_neg_shocks) if ocmaincroptercyie!=. & age > $endage, first savefirst savefprefix(st1)
boottest unlikeliness = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
estadd local controlocmain "No", replace
est sto iv1
local fstat = e(widstat)

est restore st1unlikeliness
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
estadd local controlocmain "No", replace
estadd local r2 "", replace
estadd scalar fstat = `fstat', replace
est sto iv1_first

ivreg2 z_sd $basevars $coop ocmaincroptercyie (unlikeliness = ihs_neg_shocks) if ocmaincroptercyie!=. & age > $endage, first savefirst savefprefix(st1)
boottest unlikeliness = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
estadd local controlocmain "Yes", replace
est sto iv2
local fstat = e(widstat)

est restore st1unlikeliness
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
estadd local controlocmain "Yes", replace
estadd local r2 "", replace
estadd scalar fstat = `fstat', replace
est sto iv2_first

esttab iv1_first iv1 iv2_first iv2 using "iv.tex", replace label drop(_cons $basevars coop* ocmaincroptercyie) star(* 0.1 ** 0.05 *** 0.01) ///
se(%4.3f) b(%4.3f) nogaps stat(fstat clustered commfixed controls controlocmain r2 N, fmt(2 2 3 3 3 2 0) label("F-statistic" "P-value for optimism with std. err. clustered at community level" "Community fixed effects" "Control variables" "Control for unrealistically positive self-evaluation" "R2" "Observations")) nonotes ///
mtitles("1st stage" "2nd stage" "1st stage" "2nd stage") ///
mgroups("Model 1" "Model 2", pattern(1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))


* REGRESSION TABLE: Robustness checks: IV estimates for optimism and risk-taking

estimates clear

* age polynomials

ivreg2 z_sd $basevars age2 age3 age4 age5 $coop ocmaincroptercyie (unlikeliness = ihs_neg_shocks) if ocmaincroptercyie!=. & age > $endage, first savefirst savefprefix(st1)
boottest unlikeliness = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
estadd local controlocmain "Yes", replace
estadd local agepoly "Yes", replace
estadd local allcontrol "No", replace
est sto ivrobust1
local fstat = e(widstat)

est restore st1unlikeliness
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
estadd local controlocmain "Yes", replace
estadd local agepoly "Yes", replace
estadd local allcontrol "No", replace
estadd local r2 "", replace
estadd scalar fstat = `fstat', replace
est sto ivrobust1_first


* additional controls

ivreg2 z_sd $basevars $coop ocmaincroptercyie a27_1 a27_3 a27_4 a27_5 a27_6 a27_7 mighh nonagr othersdecide littlecontrol trustpeople impatient i.selfevtercsoil i.selfevtercprofit i.landterc i.ageterc i.assets_agrterc (unlikeliness = ihs_neg_shocks) if ocmaincroptercyie!=. & age > $endage, first savefirst savefprefix(st1)
boottest unlikeliness = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
estadd local controlocmain "Yes", replace
estadd local agepoly "No", replace
estadd local allcontrol "Yes", replace
est sto ivrobust2
local fstat = e(widstat)

est restore st1unlikeliness
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
estadd local controlocmain "Yes", replace
estadd local agepoly "No", replace
estadd local allcontrol "Yes", replace
estadd local r2 "", replace
estadd scalar fstat = `fstat', replace
est sto ivrobust2_first


* other age windows

replace ihs_neg_shocks = ihs_neg_shocks_15$endage
ivreg2 z_sd $basevars $coop ocmaincroptercyie (unlikeliness = ihs_neg_shocks) if ocmaincroptercyie!=. & age > $endage, first savefirst savefprefix(st1)
boottest unlikeliness = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
estadd local controlocmain "Yes", replace
estadd local agepoly "No", replace
estadd local allcontrol "No", replace
est sto ivrobust3
local fstat = e(widstat)

est restore st1unlikeliness
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
estadd local controlocmain "Yes", replace
estadd local agepoly "No", replace
estadd local allcontrol "No", replace
estadd local r2 "", replace
estadd scalar fstat = `fstat', replace
est sto ivrobust3_first

replace ihs_neg_shocks = ihs_neg_shocks_10$endage
ivreg2 z_sd $basevars $coop ocmaincroptercyie (unlikeliness = ihs_neg_shocks) if ocmaincroptercyie!=. & age > $endage, first savefirst savefprefix(st1)
boottest unlikeliness = 0, cluster(kebele) reps(999) seed(999) 
estadd scalar clustered = r(p), replace
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
estadd local controlocmain "Yes", replace
estadd local agepoly "No", replace
estadd local allcontrol "No", replace
est sto ivrobust4
local fstat = e(widstat)

est restore st1unlikeliness
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
estadd local controlocmain "Yes", replace
estadd local agepoly "No", replace
estadd local allcontrol "No", replace
estadd local r2 "", replace
estadd scalar fstat = `fstat', replace
est sto ivrobust4_first


* correlation with assets

replace ihs_neg_shocks = ihs_neg_shocks_20$endage

reg assets_hh ihs_neg_shocks age write ihs_landsize no_0_18 no_19_54_fem no_19_54_male no_55plus riskav recent_idioshock shdisprev shseed shfert $coop if ocmaincroptercyie!=. & age > $endage, robust
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
estadd local controlocmain "No", replace
estadd local agepoly "No", replace
estadd local allcontrol "No", replace
est sto ivrobust5

reg assets_agr ihs_neg_shocks age write ihs_landsize no_0_18 no_19_54_fem no_19_54_male no_55plus riskav recent_idioshock shdisprev shseed shfert $coop if ocmaincroptercyie!=. & age > $endage, robust
estadd local commfixed "Yes", replace
estadd local controls "Yes", replace
estadd local controlocmain "No", replace
estadd local agepoly "No", replace
estadd local allcontrol "No", replace
est sto ivrobust6

esttab ivrobust1_first ivrobust1 ivrobust2_first ivrobust2 ivrobust5 ivrobust6 ivrobust3_first ivrobust3 ivrobust4_first ivrobust4 using "iv_robust.tex", replace label keep(unlikeliness ihs_neg_shocks) star(* 0.1 ** 0.05 *** 0.01) ///
se(%4.3f) b(%4.3f) nogaps stat(fstat clustered commfixed controls controlocmain agepoly allcontrol r2 N, fmt(2 2 3 3 3 3 3 2 0) label("F-statistic" "\shortstack[l]{P-value for optimism with std. err.\\clustered at community level}" "Community fixed effects" "Standard set of control variables" "Control for unrealistically positive self-evaluation" "Control for age polynomials" "Extended set of control variables" "R2" "Observations")) nonotes ///
mtitles("1st stage" "2nd stage" "1st stage" "2nd stage" "HH assets" "Agr. assets" "1st stage" "2nd stage" "1st stage" "2nd stage") ///
mgroups("Control for age polynomials" "Additional controls" "Correlation with assets" "Age window 15-30" "Age window 10-30", pattern(1 0 1 0 1 0 1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
